/**
 * 
 */
package com.witframework.baseapp;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.witframework.cache.WitCacheFactory;
import com.witframework.core.AppInitializer;
import com.witframework.core.ApplicationProperties;

/**
 * @author wuxinyang Jul 8, 2009 11:07:27 AM
 */

public class CacheInitializer implements AppInitializer {
	private static Log log = LogFactory.getLog(CacheInitializer.class);
	public void execute() {		
		initCache();
	}
	private void initCache() {
		String cacheClasses = ApplicationProperties.getProperty("hibernate.cache.class", "");
		String[] classes = StringUtils.split(cacheClasses, ",");
		for (String c : classes) {
			long s = System.currentTimeMillis();
			try {
				WitCacheFactory.getCache(Class.forName(c)).init();
			} catch (ClassNotFoundException e) {
				log.info("未找到需要缓存的实体类：" + c);
			}
			log.info(c + ":缓存加载完成:" + (System.currentTimeMillis() - s) + "ms");
		}
	}
}

    

